using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

using Material.Object;
using Material.Entity;

namespace Material.App
{
    public partial class FrmDispPiutang : Form
    {
        private string connStr = ConfigurationManager.ConnectionStrings["dbconnection"].ToString();
        private TblTransHutangHDR tblTransHutangHDR;
        private TblTransHutangHDREntity tblTransHutangHDREntity;

        public static int IdTransHDR = 0;
        public FrmDispPiutang()
        {
            InitializeComponent();
            LoadDetail();
        }

        private void rbAll_CheckedChanged(object sender, EventArgs e)
        {
            if (rbAll.Checked)
                cmbDetail.Enabled = false;
            
        }

        private void rbDetail_CheckedChanged(object sender, EventArgs e)
        {
            if (rbDetail.Checked)
                cmbDetail.Enabled = true;

            LoadDetail();
        }

        private void LoadDetail()
        {
            tblTransHutangHDREntity = new TblTransHutangHDREntity(connStr);
            cmbDetail.ValueMember = "IdTransHDR";
            cmbDetail.DisplayMember = "Nama";
            cmbDetail.DataSource = tblTransHutangHDREntity.GetDataAll();
            
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (rbAll.Checked)
            {
                FrmRptHutang frm = new FrmRptHutang();
                frm.ShowDialog();
            }
            else
            {
                FrmRptHutangDetail frmd = new FrmRptHutangDetail();
                frmd.ShowDialog();
            }
        }

        private void cmbDetail_SelectedIndexChanged(object sender, EventArgs e)
        {

            //IdTransHDR = Convert.ToInt32(cmbDetail.SelectedValue);
        }

        private void cmbDetail_SelectedValueChanged(object sender, EventArgs e)
        {
            IdTransHDR = Convert.ToInt32(cmbDetail.SelectedValue);
        }
    }
}